import 'package:dsp_bt_audio/lang/my_i19n.dart';
import 'package:flutter/material.dart';

import '../common/dialog.dart';
import '../tool/assets.dart';

class DialogAlert extends DialogWidget {
  String content;
  void Function()? onEnter;
  DialogAlert({super.key, required this.content, this.onEnter});
  @override
  DialogAlertState createState() => DialogAlertState();
}

class DialogAlertState<T extends DialogAlert> extends DialogWidgetState<T> {
  @override
  double get height => 160;
  @override
  // TODO: implement padding
  EdgeInsets get padding => EdgeInsets.only(left: 20, right: 20, bottom: 10);
  @override
  Widget get child {
    return Container(
      child: Column(
        spacing: 20,
        children: [
          Text(widget.content),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            children: [I19n.i.yes, I19n.i.no].map(($0) {
              bool isyes = $0 == I19n.i.yes;
              return Container(
                width: 60,
                height: 22,
                decoration: BoxDecoration(
                  color: isyes ? Color_theme : Colors.white,
                  border: BoxBorder.all(color: Color_theme, width: 1),
                  borderRadius: BorderRadius.circular(4),
                ),
                child: Material(
                  color: Colors.transparent,
                  child: InkWell(
                    splashColor: isyes ? Colors.white.withAlpha(100) : Color_theme.withAlpha(100),
                    highlightColor: isyes ? Colors.white.withAlpha(100) : Color_theme.withAlpha(100),
                    onTap: () {
                      Navigator.pop(context);
                      if (isyes) {
                        widget.onEnter?.call();
                      }
                    },
                    child: Center(
                      child: Text($0, style: TextStyle(color: isyes ? Colors.white : Colors.black)),
                    ),
                  ),
                ),
              );
            }).toList(),
          ),
        ],
      ),
    );
  }
}
